#include "lua_script/script.hpp"
#include "unittest.hpp"

using namespace sdl_engine::component::script;

struct Person {
    std::string name;
    int age;
    float height;
    bool female;
};

int main() {
    int aNumber;
    float aFloat;
    bool aBool;
    std::string aString;
    Person person;
    std::string tableInfo;

    LuaBridge bridge;
    bridge.DoFile("assets/test.lua")
          .Get(aNumber, "aNumber")
          .Get(aFloat, "aFloat")
          .Get(aBool, "aBool")
          .Get(aString, "aString")
          .StartTable("aDict")
              .Get(tableInfo, "info")
              .StartTable("person")
                  .Get(person.name, "name")
                  .Get(person.age, "age")
                  .Get(person.female, "female")
                  .Get(person.height, "height")
              .EndTable()
          .EndTable();

    assert(aNumber == 12);
    assert(aFloat == 123.3f);
    assert(aBool == false);
    assert(aString == "string");
    assert(person.name == "TestName");
    assert(person.age == 114514);
    assert(person.female == false);
    assert(person.height == 74.751f);
    assert(tableInfo == "this is a dict");

    return 0;
}
